
import {
	BASE_URL
} from './request.js';
export const uploadFiles = (options) => {
	var token = uni.getStorageSync("token") || "2ff8144d-306d-4817-9c4a-d5e4d08530ad";
	return new Promise((resolve, reject) => {
		console.log(options)
		const uploadTask = uni.uploadFile({
			url: BASE_URL+'/api/attachments/Upload',
			header: {
				"Content-Type": "application/json",
				token
			},
			filePath: options.filePath,
			formData: options.formData,
			name: 'file',
			success(res) {
				let data = JSON.parse(res.data)
					resolve(data[0].attachment)
			},
			fail(err) {
				uni.showToast({
					title: '请求超时！',
					icon: 'none'
				})
				reject(err)
			},
			complete() {
				uni.hideLoading()
			}
		})
	})
}


module.exports = {
	uploadFiles
}
